using Dapper;
using MediatR;
using MeetingManagement.Application.Commands;
using MeetingManagement.Application.Models;
using MeetingManagement.Application.Queries;

namespace MeetingManagement.Application.Users
{
    public class GetAllUsersQueryHandler : QueryBase, IRequestHandler<GetAllUsersQuery, IEnumerable<UserDto>>
    {
        public GetAllUsersQueryHandler(QuerySettings settings) : base(settings)
        {
        }

        public async Task<IEnumerable<UserDto>> Handle(GetAllUsersQuery request, CancellationToken cancellationToken)
        {
            var sql = @"SELECT * FROM User";

            return await ExecuteAsync(conn => conn.QueryAsync<UserDto>(sql, request));
        }
    }
}
